package actions;

import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import donnees.Categorie;
import metier.*;

public class ActionVoirPageAccueil extends UnicastRemoteObject implements IAction{
	private static final long serialVersionUID = 3833966865998364181L;

	public ActionVoirPageAccueil() throws RemoteException {
		super();
	}

	@Override
	public String execute(HttpServletRequest req) throws Exception{
		HttpSession theSession=req.getSession(true);
		IMetier metier=(IMetier)Naming.lookup("rmi://localhost:2000/ServeurMetier");
		if(theSession.getAttribute("lesCategories")==null){
			theSession.setAttribute("lesCategories", ((ArrayList<Categorie>) metier.getCategories()));
		}
		return "accueil.jsp";
	}
}
